import { VueConstructor } from 'vue'
import RegApp from './regApp'
import { ITagView, TagsViewModule } from '@/store/modules/tags-view'

const install = (Vue: VueConstructor, option: any) => {
  let regApp!: RegApp

  Vue.mixin({
    beforeCreate() {
      // console.log('this ->', this)
      if (!regApp) {
        regApp = new RegApp(this, option.regData)
      }
    }
  })
  Object.defineProperty(Vue.prototype, '$regApp', {
    get() {
      return regApp
    }
  })
  Object.defineProperty(Vue.prototype, '$setTagName', {
    get() {
      return (route: ITagView) => {
        // console.log('setTitle ->', route)
        // TagsViewModule.setTagViewTitle(route)
      }
    }
  })
}
export default {
  install
}
